﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using Newtonsoft.Json.Linq;

namespace Sina.Altman.Weibo.SDK.Objects
{
    public class Friends
    {
        public Friends(string json)
         : this(JObject.Parse(json))
        {
        }

        private JObject __jobject;
        public Friends(JObject obj)
        {
            this.__jobject = obj;
        }

        [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
        private User[] _users;
        public User[] Users
        {
            get
            {
                if(_users == null)
                    _users = (User[])JsonClassHelper.ReadArray<User>(JsonClassHelper.GetJToken<JArray>(__jobject, "users"), JsonClassHelper.ReadStronglyTypedObject<User>, typeof(User[]));
                return _users;
            }
        }

        public int NextCursor
        {
            get
            {
                return JsonClassHelper.ReadInteger(JsonClassHelper.GetJToken<JValue>(__jobject, "next_cursor"));
            }
        }

        public int PreviousCursor
        {
            get
            {
                return JsonClassHelper.ReadInteger(JsonClassHelper.GetJToken<JValue>(__jobject, "previous_cursor"));
            }
        }

        public int TotalNumber
        {
            get
            {
                return JsonClassHelper.ReadInteger(JsonClassHelper.GetJToken<JValue>(__jobject, "total_number"));
            }
        }
    }
}
